#pragma once
#include "meeting.h"
#include <comutil.h> 
#define MAX_BALANCE_NET			150
struct MeetingParam
{
	CString Subject;
	long MaxMemberCount; 
	long DefaultSpeakMemberCount; 
	long MaxSpeakMemberCount; 
	long Mode; 
	CString PresiderName; 
	CString PresiderTel; 
	long PresiderTelType; 
	long PresiderCallMode; 
	long PresiderDefaultMikeState; 
	CString PresiderPassword; 
	CString MemberPassword; 
	CString ANI; 
	long SMSNotify; 
	CString StartDateTime;
	CString EndDateTime;
	CString MeetingRecordFileURL;
	CString MeetingLogURL;
	long MeetingState;
	CString Tag;
};

struct MeetingMemberParam
{
	CString MemberName;
	CString MemberTel;
	long MemberTelType;
	long MemberCallMode;
	long DefaultMikeState;
};


class CMeetWrapper:public CMeeting
{
public:
    CMeetWrapper(void);
public:
    virtual ~CMeetWrapper(void);
public:
    void test()
    {

    }

    long TM_Login(LPCTSTR Host, long Port, LPCTSTR UserID, LPCTSTR Passwd, CString& Lic)
    {
        CComBSTR bstrResult;

        long lRet;
        lRet = CMeeting::TM_Login(Host, Port, UserID, Passwd, &bstrResult);

        char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
        Lic = lpszText2;

        delete[] lpszText2;

        return lRet;  
    }

    long TM_RegMeeting(LPCTSTR Subject, LPCTSTR Tag, long MaxMemberCount, long DefaultSpeakMemberCount, long MaxSpeakMemberCount, long Mode, LPCTSTR PresiderName, LPCTSTR PresiderTel, long PresiderTelType, long PresiderCallMode, long PresiderDefaultMikeState, LPCTSTR PresiderPassword, LPCTSTR MemberPassword, LPCTSTR ANI, long SMSNotify, LPCTSTR StartDateTime, LPCTSTR EndDateTime, CString& MeetingNumber)
    {
        CComBSTR bstrResult = MeetingNumber.AllocSysString();

        long lRet;
        lRet = CMeeting::TM_RegMeeting(Subject, Tag, MaxMemberCount, DefaultSpeakMemberCount, MaxSpeakMemberCount, Mode, PresiderName, PresiderTel, PresiderTelType, PresiderCallMode, PresiderDefaultMikeState, PresiderPassword, MemberPassword, ANI, SMSNotify, StartDateTime, EndDateTime, &bstrResult);

        char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
        MeetingNumber = lpszText2;

        delete[] lpszText2;

        return lRet;
    }

    long TM_RegMeeting(MeetingParam& aParam, CString& MeetingNumber)
    {
        return TM_RegMeeting(aParam.Subject, aParam.Tag, aParam.MaxMemberCount, aParam.DefaultSpeakMemberCount, aParam.MaxSpeakMemberCount, aParam.Mode, aParam.PresiderName, aParam.PresiderTel, aParam.PresiderTelType, aParam.PresiderCallMode, aParam.PresiderDefaultMikeState, aParam.PresiderPassword, aParam.MemberPassword, aParam.ANI, aParam.SMSNotify, aParam.StartDateTime, aParam.EndDateTime, MeetingNumber);
    }

    long TM_GetMeetingList(CString& MeetingNumbers)
	{
		CComBSTR bstrResult;

		long lRet;
		lRet = CMeeting::TM_GetMeetingList( &bstrResult);

		char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
		MeetingNumbers = lpszText2;

		delete[] lpszText2;

		return lRet;     
	}

	long TM_SetMeetingParam(LPCTSTR MeetingNumber, MeetingParam &aParam)
	{
		return CMeeting::TM_SetMeetingParam(MeetingNumber, aParam.Subject, aParam.Tag, aParam.MaxMemberCount, aParam.DefaultSpeakMemberCount, aParam.MaxSpeakMemberCount, aParam.Mode, aParam.PresiderName, aParam.PresiderTel, aParam.PresiderTelType, aParam.PresiderCallMode, aParam.PresiderDefaultMikeState, aParam.PresiderPassword, aParam.MemberPassword, aParam.ANI, aParam.SMSNotify, aParam.StartDateTime, aParam.EndDateTime);
	}
    
	//long TM_GetMeetingState(LPCTSTR MeetingNumber)
	//{
	//	return CMeeting::TM_GetMeetingState(MeetingNumber);
	//}

	long TM_GetMeetingParam( LPCTSTR MeetingNumber, MeetingParam& aParam)
	{
		return TM_GetMeetingParam(MeetingNumber, aParam.Subject, aParam.Tag, &aParam.MaxMemberCount, &aParam.DefaultSpeakMemberCount, &aParam.MaxSpeakMemberCount, &aParam.Mode, aParam.PresiderName, aParam.PresiderTel, &aParam.PresiderTelType, &aParam.PresiderCallMode, &aParam.PresiderDefaultMikeState, aParam.PresiderPassword, aParam.MemberPassword, aParam.ANI, &aParam.SMSNotify, aParam.StartDateTime, aParam.EndDateTime, aParam.MeetingRecordFileURL, aParam.MeetingLogURL, &aParam.MeetingState);
	}

    long TM_GetMeetingParam(LPCTSTR MeetingNumber, CString& Subject, CString& Tag, long * MaxMemberCount, long * DefaultSpeakMemberCount, long * MaxSpeakMemberCount, long * Mode, CString& PresiderName, CString& PresiderTel, long * PresiderTelType, long * PresiderCallMode, long * PresiderDefaultMikeState, CString& PresiderPassword, CString& MemberPassword, CString& ANI, long * SMSNotify, CString& StartDateTime, CString& EndDateTime, CString& MeetingRecordFileURL, CString& MeetingLogURL, long* MeetingState)
    {
        CComBSTR _Subject;
		CComBSTR _Tag;
        CComBSTR _PresiderName;
        CComBSTR _PresiderTel;
        CComBSTR _PresiderPassword;
        CComBSTR _MemberPassword;
        CComBSTR _ANI;
        CComBSTR _StartDateTime;
        CComBSTR _EndDateTime;
		CComBSTR _MeetingRecordFileURL;
		CComBSTR _MeetingLogURL;
			 
        long lRet;
        lRet = CMeeting::TM_GetMeetingParam(MeetingNumber, &_Subject, &_Tag, MaxMemberCount, DefaultSpeakMemberCount, MaxSpeakMemberCount, Mode, &_PresiderName, &_PresiderTel, PresiderTelType, PresiderCallMode, PresiderDefaultMikeState, &_PresiderPassword, &_MemberPassword, &_ANI, SMSNotify, &_StartDateTime, &_EndDateTime, &_MeetingRecordFileURL, &_MeetingLogURL, MeetingState);


        char* lp_Subject = _com_util::ConvertBSTRToString(_Subject);
        Subject = lp_Subject;
        delete[] lp_Subject;

		char* lp_Tag = _com_util::ConvertBSTRToString(_Tag);
		Tag = lp_Tag;
		delete[] lp_Tag;

        char* lp_PresiderName = _com_util::ConvertBSTRToString(_PresiderName);
        PresiderName = lp_PresiderName;
        delete[] lp_PresiderName;

        char* lp_PresiderTel = _com_util::ConvertBSTRToString(_PresiderTel);
        PresiderTel = lp_PresiderTel;
        delete[] lp_PresiderTel;

        char* lp_PresiderPassword = _com_util::ConvertBSTRToString(_PresiderPassword);
        PresiderPassword = lp_PresiderPassword;
        delete[] lp_PresiderPassword;

        char* lp_MemberPassword = _com_util::ConvertBSTRToString(_MemberPassword);
        MemberPassword = lp_MemberPassword;
        delete[] lp_MemberPassword;

        char* lp_ANI = _com_util::ConvertBSTRToString(_ANI);
        ANI = lp_ANI;
        delete[] lp_ANI;

        char* lp_StartDateTime = _com_util::ConvertBSTRToString(_StartDateTime);
        StartDateTime = lp_StartDateTime;
        delete[] lp_StartDateTime;

        char* lp_EndDateTime = _com_util::ConvertBSTRToString(_EndDateTime);
        EndDateTime = lp_EndDateTime;
        delete[] lp_EndDateTime;

		char* lp_MeetingRecordFileURL = _com_util::ConvertBSTRToString(_MeetingRecordFileURL);
		MeetingRecordFileURL = _MeetingRecordFileURL;
		delete[] lp_MeetingRecordFileURL;

		char* lp_MeetingLogURL = _com_util::ConvertBSTRToString(_MeetingLogURL);
		MeetingLogURL = _MeetingLogURL;
		delete[] lp_MeetingLogURL;

        return lRet;

    }
   
	long TM_AddMember(LPCTSTR MeetingNumber, CString& MemberID,  MeetingMemberParam aParam)
	{
		return TM_AddMember(MeetingNumber, aParam.MemberName, aParam.MemberTel, aParam.MemberTelType, aParam.MemberCallMode, aParam.DefaultMikeState, MemberID);
	}
    long TM_AddMember(LPCTSTR MeetingNumber, LPCTSTR MemberName, LPCTSTR MemberTel, long MemberTelType, long MemberCallMode, long DefaultMikeState, CString& MemberID)
    {
        CComBSTR bstrResult;

        long lRet;
        lRet = CMeeting::TM_AddMember(MeetingNumber, MemberName, MemberTel, MemberTelType, MemberCallMode, DefaultMikeState,  &bstrResult);

        char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
        MemberID = lpszText2;

        delete[] lpszText2;

        return lRet;   
    }

	long TM_StartAddMemberList(LPCTSTR MeetingNumber)
	{
		return CMeeting::TM_StartAddMemberList(MeetingNumber);
	}

	long TM_AddMemberList(MeetingMemberParam aParam)
	{
		return TM_AddMemberList(aParam.MemberName, aParam.MemberTel, aParam.MemberTelType, aParam.MemberCallMode, aParam.DefaultMikeState);
	}

	long TM_AddMemberList(LPCTSTR MemberName, LPCTSTR MemberTel, long MemberTelType, long MemberCallMode,long DefaultMikeState)
	{
		return CMeeting::TM_AddMemberList( MemberName, MemberTel, MemberTelType, MemberCallMode, DefaultMikeState );
	}

	long TM_AddMemberListSubmit(CString& MemberIDs)
	{
		CComBSTR bstrResult;

		long lRet;
		lRet = CMeeting::TM_AddMemberListSubmit(&bstrResult);

		char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
		MemberIDs = lpszText2;

		delete[] lpszText2;

		return lRet;     
	}

    
    long TM_GetMemberList(LPCTSTR MeetingNumber, CString& MemberIDs)
    {
        CComBSTR bstrResult;

        long lRet;
        lRet = CMeeting::TM_GetMemberList(MeetingNumber, &bstrResult);

        char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
        MemberIDs = lpszText2;

        delete[] lpszText2;

        return lRet;     
    }

	long TM_GetMember(LPCTSTR MeetingNumber, LPCTSTR MemberID, MeetingMemberParam &aParam)
	{
		return TM_GetMember(MeetingNumber, MemberID, aParam.MemberName, aParam.MemberTel, &aParam.MemberTelType, &aParam.MemberCallMode, &aParam.DefaultMikeState);
	}
    long TM_GetMember(LPCTSTR MeetingNumber, LPCTSTR MemberID, CString& MemberName, CString& MemberTel, long * MemberTelType, long * MemberCallMode, long * DefaultMikeState)
    {
        CComBSTR _MemberName;
        CComBSTR _MemberTel;
        

        long lRet;
        lRet = CMeeting::TM_GetMember(MeetingNumber, MemberID, &_MemberName, &_MemberTel, MemberTelType, MemberCallMode, DefaultMikeState);



        char* lp_MemberName = _com_util::ConvertBSTRToString(_MemberName);
        MemberName = lp_MemberName;
        delete[] lp_MemberName;

        char* lp_MemberTel = _com_util::ConvertBSTRToString(_MemberTel);
        MemberTel = lp_MemberTel;
        delete[] lp_MemberTel;

        

        return lRet;

    }
  
    long TM_GetMeetingLogURL(LPCTSTR MeetingNumber, long Mode, CString& URL)
    {
        CComBSTR bstrResult;

        long lRet;
        lRet = CMeeting::TM_GetMeetingLogURL(MeetingNumber, Mode, &bstrResult);

        char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
        URL = lpszText2;

        delete[] lpszText2;

        return lRet;        
    }
    long TM_GetMeetingRecordFileURL(LPCTSTR MeetingNumber, long Mode, CString& URL)
    {
        CComBSTR bstrResult;

        long lRet;
        lRet = CMeeting::TM_GetMeetingRecordFileURL(MeetingNumber, Mode, &bstrResult);

        char* lpszText2 = _com_util::ConvertBSTRToString(bstrResult);
        URL = lpszText2;

        delete[] lpszText2;

        return lRet; 
    }
    
};
